package pages;

import org.openqa.selenium.WebElement;

import io.appium.java_client.AppiumBy;
import io.appium.java_client.android.AndroidDriver;
import utiles.BaseAction;

public class PersonPage {
	AndroidDriver driver;
	BaseAction action;
	
	public PersonPage(AndroidDriver driver) {
		this.driver=driver;
		action=new BaseAction(driver);
	}
	
	public WebElement btn_editInformation() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/btn_confirm"));
	}
	
	public WebElement edit_name() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/et_name"));
	}
	
	public WebElement edit_age() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/et_age"));
	}
	
	public WebElement edit_gender() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/et_gender"));
	}
	
	public WebElement edit_nation() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/et_nation"));
	}
	
	public WebElement edit_height() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/et_height"));
	}
	
	public WebElement edit_weight() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/et_weight"));
	}
	
	public WebElement btn_confirmInformation() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/btn_confirm"));
	}
	
	public void editInformation(String name,String age,String gender,String nation,String height,String weight) 
			throws InterruptedException {
		action.click(this.btn_editInformation());
		action.typeAndClear(this.edit_name(),name);
		action.typeAndClear(this.edit_age(),age);
		action.typeAndClear(this.edit_gender(),gender);
		action.typeAndClear(this.edit_nation(),nation);
		action.typeAndClear(this.edit_height(),height);
		action.typeAndClear(this.edit_weight(),weight);
		action.click(this.btn_confirmInformation());     
	}	
	
	public String editInformationSuccess
	(String name,String age,String gender,String nation,String height,String weight) throws InterruptedException {
		editInformation(name,age,gender,nation,height,weight);
		return action.getToastMsg();
	}
	
	public WebElement btn_exerciseLog() {
		return driver.findElement(AppiumBy.id("njust.dzh.fitnesssystem:id/btn_log"));
	}
	
	public void edit_ExerciseLog() throws InterruptedException {
		action.click(this.btn_exerciseLog());
	}
	
	public LogPage edit_ExerciseLogSuccess() throws InterruptedException {
		edit_ExerciseLog();
		return new LogPage(driver);
	}

}
